import { HttpUrlVariable } from '@/constants'
import type { CreateOrderResult, OrderParams, OrderPreData, OrderPreParams } from '@/types/consult.d'
import type { DepartData } from '@/types/user'
import type { ConsultRecordParams, ConsultRecordRes, ConsultRecord } from '@/types/consult.ts'
import RequestHttp from '@/utils/request'
import type { OrderDetailParams } from '@/types/consult.d'
import type { OrderDetailData } from '@/types/consult.d'

export const getConsultListAPI = () =>
  RequestHttp.get<DepartData[]>(HttpUrlVariable.CONSULT_LIST_URL)

/**
 * 获取预订单信息
 * **/
export const getPreOrderAPI = (params: OrderPreParams) =>
  RequestHttp.get<OrderPreData, OrderPreParams>(HttpUrlVariable.PRE_ORDER_URL, params)

/**
 * 创建订单接口
 * **/
export const createOrderAPI = (data: OrderParams) =>
  RequestHttp.post<CreateOrderResult, OrderParams>(HttpUrlVariable.CREATE_ORDER_URL, data)

/**
 * 获取问诊记录列表
 */
export const getConsultRecordAPI = (params: ConsultRecordParams) =>
  RequestHttp.get<ConsultRecordRes>(HttpUrlVariable.CONSULT_RECORD_URL, params)

/**
 * 获取问诊详情
 */
export const getConsultDetailAPI = (id: string) =>
  RequestHttp.get<ConsultRecord>(`${HttpUrlVariable.CONSULT_DETAIL_URL}${id}`)


// 获取订单详情
export const getOrderDetailAPI = (orderId: string) =>
  RequestHttp.get<OrderDetailData, OrderDetailParams>(HttpUrlVariable.CONSULT_DETAIL_URL, {
    orderId,
  })
